server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # Frontend
    location / {
        proxy_pass http://front:8080/; # same name as network alias
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    # api
    location /api/ {
        proxy_pass http://core_api:2222/api/;
    }
    # api docs
    location /docs {
        proxy_pass http://core_api:2222/docs;
    }
    location /openapi.json {
        proxy_pass http://core_api:2222/openapi.json;
    }
    # for fastapi swaggerUI
    # location /openapi.json {
    #     proxy_pass http://backend:5000/openapi.json;
    # }

    # You may need this to prevent return 404 recursion.
    location = /404.html {
        internal;
    }
}